package com.lin.utils;


import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5 {
	private static MD5 md5 = new MD5();
	public static MD5 getMD5(){
		return md5;
	}
	public  String getMd5(String key ){
		try {
			MessageDigest messageDigest = MessageDigest.getInstance("MD5");
			messageDigest.update(key.getBytes());
			byte[] mBytes = messageDigest.digest();
			return getString(mBytes);
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		return null;
	}
	private String getString(byte[] mBytes){
		
		StringBuffer mStringBuffer = new StringBuffer();
		for(int i = 0 ; i < mBytes.length ; i ++){
			mStringBuffer.append(mBytes[i]);
		}
		return mStringBuffer.toString();
	}
	
	/**
	 * @brief 简单加解密
	 * @todo 等待修改
	 */
	public String en(String str,String key)
	{
		return str;
	}
	
	public String de(String str,String key)
	{
		return str;
	}

	
}
